<template>
	<view>
		<uni-popup ref="popup" :type="type" :mask-click="mask" @maskClick="maskClick">
			<slot></slot>
		</uni-popup>
	</view>
</template>

<script>
	export default {
		emits: ["tipsOpen", "tipsClose"],
		props: {
			showTips: {
				type: Boolean,
				default: false
			},
			type: {
				type: String,
				default: "center"
			},
			mask: {
				type: Boolean,
				default: false
			},
		},
		data() {
			return {

			}
		},
		watch: {
			showTips(val) {
				if (val) {
					this.open()
				} else {
					this.close();
				}
			}
		},
		methods: {
			maskClick() {
				if (this.mask) {
					this.$refs.popup.close();
					this.$emit("tipsClose", false);
				}

			},
			open() {
				this.$refs.popup.open();
				this.$emit("tipsOpen", true);
			},
			close() {
				this.$refs.popup.close();
				this.$emit("tipsClose", false);
			},
		},
	}
</script>

<style scoped lang="scss">

</style>